<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />

		<title></title>
		<script src="../../js/mui.min.js"></script>
		<link href="../../css/mui.min.css" rel="stylesheet" />
		<script src="../../js/getURLParam.js"></script>
		<link rel="stylesheet" href="../../css/global.css">
		<style>
			html,
			body {
				background-color: #efeff4;
			}
			/*控制a标签样式*/
			a:link {color:#000000}

			a:hover {color:#000000}
			
			a:visited {color:#000000}
			
			a:active {color:#000000}
		</style>
	</head>

	<body class="bodyback">
		<div id="flthidden" >
		<div class="mui-content" style="padding-top: 0;">
			<div id="page1" class="mui-control-content mui-active" style="height:90px;background-color:white" >
				<ul class="mui-table-view mui-table-view-striped mui-table-view-condensed" style="height:90px">
					<li class="mui-table-view-cell">
						<div class="mui-table">
							<div class="mui-table-cell mui-col-xs-10" >
								<span>
								<h5 class="mui-ellipsis"><div style="float:left;width:75%" id="lastPosition"></div> 
									<div style="color:#149DDD;width:25%;float:right;" id="vclFltServiceSation">附近服务站</div>
									<p class="mui-h6" style="height: auto;padding-top:20px" id="fltInfo">
									</p>
								</h5>
								</span>
							</div>
						</div>
					</li>
				</ul>
			</div>
		</div>
		
       <div class="mui-content" id="curtflt">
        	<div id="scroll" class="mui-scroll-wrapper" style="margin-top:90px;">
				<div class="mui-scroll">
					<ul class="mui-table-view" id='flt' style="width:100%">
					</ul>
				</div>
			</div>
        </div>
 </div>
		<script type="text/javascript" charset="utf-8">
			//mui初始化 
		//	mui.init();
			mui.init({
				pullRefresh: {
					container: '#scroll',
					down: {
						callback: test
					}
				}
			});
			function test(){
				setTimeout(function() {
					//ajax请求获取单车现行故障
			mui.ajax('../../../APP/fltCurList', {
				data: {
					param: '{"proVersion":"' + proversion + '","accountId":"' + accountid + '","sessionid":"' + sessionid + '","data":{"vclId":"' + vclid + '"}}'
				},
				dataType: 'jsonp', //服务器返回json格式数据
				type: 'post', //HTTP请求类型
				timeout: 100000, //超时时间设置为10秒；
				success: function(data) {
					var jsonObj = window.JSON.parse(data);
					var resultEle=document.getElementById("fltInfo");
					if (jsonObj.resultCode == "1") {
						//获取返回数据的data
						var resultdata = jsonObj.data;
						if (null != resultdata) {
							var vehiclecontact=resultdata.vehiclecontact;
							var enginfactorynamecn=resultdata.enginfactorynamecn;
							var hosname=resultdata.hosname;
							lng=resultdata.lng;//纬度
							lat=resultdata.lat;//经度
							getPosition();//获取位置
							var fltresult=""
							var telphoneString="";
							var onclickString="";
							if(vehiclecontact!=""&&vehiclecontact!=null){
								if(null!=resultdata.vehiclechargedmobile&&""!=resultdata.vehiclechargedmobile){
									telphoneString='<img width="25px" style="vertical-align:middle" src="../../images/drawable-mdpi/tel_blue.png">';
									onclickString="onclick=tel1(this)";
								}else{
									telphoneString='<img width="25px" style="vertical-align:middle" src="../../images/drawable-mdpi/tel_grey.png">';
									onclickString="";
								}
								fltresult+='<div '+onclickString+' style="float:left;width:30%;" id="tel1"  name="tel_'+resultdata.vehiclechargedmobile+'">'
								fltresult+='<span id="vclUser">'+vehiclecontact+'</span>'
								fltresult+=telphoneString
								fltresult+='</div>';
							}
							/*if(enginfactorynamecn!=""&&enginfactorynamecn!=null){
								if(null!=resultdata.mobile&&""!=resultdata.mobile){
									telphoneString='<img width="25px" style="vertical-align:middle" src="../../images/drawable-mdpi/tel_blue.png">';
									onclickString="onclick=tel2(this)";
								}else{
									telphoneString='<img width="25px" style="vertical-align:middle" src="../../images/drawable-mdpi/tel_grey.png">';
									onclickString="";
								}
								fltresult+='<div '+onclickString+' style="float:left" id="tel2" name="tel_'+resultdata.mobile+'">'
								fltresult+=telphoneString
								fltresult+='<span id="vclUser">'+enginfactorynamecn+'</span>'
								fltresult+='</div>';
							}*/
							if(hosname!=""&&hosname!=null){
								if(null!=resultdata.hostel&&""!=resultdata.hostel){
									telphoneString='<img width="25px" style="vertical-align:middle" src="../../images/drawable-ldpi/dianhua1.png">';
									onclickString="onclick=tel3(this)";
								}else{
									telphoneString='<img width="25px" style="vertical-align:middle" src="../../images/drawable-ldpi/diainhua_gary.png">';
									onclickString="";
								}
								fltresult+='<div '+onclickString+'  style="float:left;width:40%;" id="tel3" name="tel_'+resultdata.hostel+'">'
								fltresult+='<span id="vclUser" style="font-size:14px;color:#009acd">'+hosname+'</span>'
								fltresult+=telphoneString;
								fltresult+='</div>';
							}
							fltresult+='<div onclick="tel4(this)"  style="float:left;width:30%;text-align:right" id="tel4" name="tel_400-688-0416">'
								fltresult+='<span id="vclUser" style="font-size:14px;color:#009acd">康明斯</span>'
								fltresult+='<img width="25px" style="vertical-align:middle" src="../../images/drawable-ldpi/dianhua1.png">'
								fltresult+='</div>';
							resultEle.innerHTML=fltresult;
							var fltCont="";
							if(null!=resultdata.fltlist&&resultdata.fltlist.length>0){
								
								for(var i=0;i<resultdata.fltlist.length;i++){
									var fltcont=resultdata.fltlist[i].fltcont;
									if(null==fltcont){
										fltcont="";
									}
									var fltrisk=resultdata.fltlist[i].fltrisk;
									if(null==fltrisk){
										fltrisk="";
									}
									fltCont+='<li class="mui-table-view-cell">';
									fltCont+='<div class="mui-table-cell mui-col-xs-10">'
									fltCont+='<span><h5 style="color:'+resultdata.fltlist[i].fltcolor+'" class="mui-ellipsis">'+resultdata.fltlist[i].fltcode+'&nbsp;&nbsp;报警中 <p style="display: inline;color:grey;float:right">'+resultdata.fltlist[i].flttime+'</p></h5></span>'
									fltCont+='<p class="mui-h6" style="height: auto;">故障描述:'+fltcont+'</p>'
									
									fltCont+='<p class="mui-h6" style="height: auto;">友善提示：'+fltrisk+'</p>'
									fltCont+='</div>'
									/*fltCont+='<p style="background-color: white;text-indent: 0px;margin: 0px;padding: 4px;">';
									fltCont+='<span style="color: '+resultdata.fltlist[i].fltcolor+';font-size: 12px;">'+resultdata.fltlist[i].fltcode+'&nbsp;&nbsp;&nbsp;'+resultdata.fltlist[i].fltrisk+'</span></p>';*/
									fltCont+='</li>';
								}
								curtflt.innerHTML=fltCont;
							}else{
								fltCont+='<li class="mui-table-view-cell">';
									fltCont+='<div class="mui-col-xs-10" style="text-align:center">'
									fltCont+='<p class="mui-h6" style="height: auto;">车辆没有现行故障</p>'
									fltCont+='</div>'
									fltCont+='</li>';
								curtflt.innerHTML=fltCont;
							}
							
						} else {
							curtflt.innerHTML="车辆没有现行故障";
						}
			
					} else {
						curtflt.innerHTML = "请求出错!" + jsonObj.resultCode;
						document.getElementById("isloading").style.display="none";
					}
				},
				error: function(xhr, type, errorThrown) {
				}
			});
					mui('#scroll').pullRefresh().endPulldownToRefresh(); //refresh completed
				}, 1500);
			};
			(function($) {
				$('#scroll').scroll({
					indicators: true //是否显示滚动条
				});
			})(mui);
			var sessionid=GetQueryString("sessionid");
	        var accountid=GetQueryString("accountid");
	        var proversion=GetQueryString("proversion");
	        var vclid = GetQueryString("vclid");
			var curtflt = document.getElementById("flt");
			var fltCont = "无故障记录";
			var lng="0";
			var lat="0";
			//ajax请求获取单车现行故障
			mui.ajax('../../../APP/fltCurList', {
				data: {
					param: '{"proVersion":"' + proversion + '","accountId":"' + accountid + '","sessionid":"' + sessionid + '","data":{"vclId":"' + vclid + '"}}'
				},
				dataType: 'jsonp', //服务器返回json格式数据
				type: 'post', //HTTP请求类型
				timeout: 100000, //超时时间设置为10秒；
				success: function(data) {
					var jsonObj = window.JSON.parse(data);
					var resultEle=document.getElementById("fltInfo");
					if (jsonObj.resultCode == "1") {
						//获取返回数据的data
						var resultdata = jsonObj.data;
						if (null != resultdata) {
							var vehiclecontact=resultdata.vehiclecontact;
							var enginfactorynamecn=resultdata.enginfactorynamecn;
							var hosname=resultdata.hosname;
							lng=resultdata.lng;//纬度
							lat=resultdata.lat;//经度
							getPosition();//获取位置
							var fltresult=""
							var telphoneString="";
							var onclickString="";
							if(vehiclecontact!=""&&vehiclecontact!=null){
								if(null!=resultdata.vehiclechargedmobile&&""!=resultdata.vehiclechargedmobile){
									telphoneString='<img width="25px" style="vertical-align:middle" src="../../images/drawable-mdpi/tel_blue.png">';
									onclickString="onclick=tel1(this)";
								}else{
									telphoneString='<img width="25px" style="vertical-align:middle" src="../../images/drawable-mdpi/tel_grey.png">';
									onclickString="";
								}
								fltresult+='<div '+onclickString+' style="float:left;width:30%" id="tel1"  name="tel_'+resultdata.vehiclechargedmobile+'">'
								fltresult+='<span id="vclUser" >'+vehiclecontact+'</span>'
								fltresult+=telphoneString
								fltresult+='</div>';
							}
							/*if(enginfactorynamecn!=""&&enginfactorynamecn!=null){
								if(null!=resultdata.mobile&&""!=resultdata.mobile){
									telphoneString='<img width="25px" style="vertical-align:middle" src="../../images/drawable-mdpi/tel_blue.png">';
									onclickString="onclick=tel2(this)";
								}else{
									telphoneString='<img width="25px" style="vertical-align:middle" src="../../images/drawable-mdpi/tel_grey.png">';
									onclickString="";
								}
								fltresult+='<div '+onclickString+' style="float:left" id="tel2" name="tel_'+resultdata.mobile+'">'
								fltresult+=telphoneString
								fltresult+='<span id="vclUser">'+enginfactorynamecn+'</span>'
								fltresult+='</div>';
							}*/
							if(hosname!=""&&hosname!=null){
								if(null!=resultdata.hostel&&""!=resultdata.hostel){
									telphoneString='<img width="25px" style="vertical-align:middle" src="../../images/drawable-ldpi/dianhua1.png">';
									onclickString="onclick=tel3(this)";
								}else{
									telphoneString='<img width="25px" style="vertical-align:middle" src="../../images/drawable-ldpi/dianhua_gary.png">';
									onclickString="";
								}
								fltresult+='<div '+onclickString+'  style="float:left;width:40%" id="tel3" name="tel_'+resultdata.hostel+'">'
								fltresult+='<span id="vclUser" style="font-size:14px;color:#009acd">'+hosname+'</span>'
								fltresult+=telphoneString;
								fltresult+='</div>';
							}
								fltresult+='<div onclick="tel4(this)"  style="float:left;width:30%;text-align:right" id="tel4" name="tel_400-688-0416">'
								fltresult+='<span id="vclUser" style="font-size:14px;color:#009acd">康明斯</span>'
								fltresult+='<img width="25px" style="vertical-align:middle" src="../../images/drawable-ldpi/dianhua1.png">'
								fltresult+='</div>';
							resultEle.innerHTML=fltresult;
							var fltCont="";
							if(null!=resultdata.fltlist&&resultdata.fltlist.length>0){
								
								for(var i=0;i<resultdata.fltlist.length;i++){
									var fltcont=resultdata.fltlist[i].fltcont;
									if(null==fltcont){
										fltcont="";
									}
									var fltrisk=resultdata.fltlist[i].fltrisk;
									if(null==fltrisk){
										fltrisk="";
									}
									fltCont+='<li class="mui-table-view-cell">';
									fltCont+='<div class="mui-table-cell mui-col-xs-10">'
									fltCont+='<span><h5 style="color:'+resultdata.fltlist[i].fltcolor+'" class="mui-ellipsis">'+resultdata.fltlist[i].fltcode+'&nbsp;&nbsp;报警中 <p style="display: inline;color:grey;float:right">'+resultdata.fltlist[i].flttime+'</p></h5></span>'
									fltCont+='<p class="mui-h6" style="height: auto;">故障描述:'+fltcont+'</p>'
									
									fltCont+='<p class="mui-h6" style="height: auto;">友善提示：'+fltrisk+'</p>'
									fltCont+='</div>'
									/*fltCont+='<p style="background-color: white;text-indent: 0px;margin: 0px;padding: 4px;">';
									fltCont+='<span style="color: '+resultdata.fltlist[i].fltcolor+';font-size: 12px;">'+resultdata.fltlist[i].fltcode+'&nbsp;&nbsp;&nbsp;'+resultdata.fltlist[i].fltrisk+'</span></p>';*/
									fltCont+='</li>';
								}
								curtflt.innerHTML=fltCont;
							}else{
								fltCont+='<li class="mui-table-view-cell">';
									fltCont+='<div class="mui-col-xs-10" style="text-align:center">'
									fltCont+='<p class="mui-h6" style="height: auto;">车辆没有现行故障</p>'
									fltCont+='</div>'
									fltCont+='</li>';
								curtflt.innerHTML=fltCont;
							}
							
						} else {
							curtflt.innerHTML="车辆没有现行故障";
						}
			
					} else {
						curtflt.innerHTML = "请求出错!" + jsonObj.resultCode;
						document.getElementById("isloading").style.display="none";
					}
				},
				error: function(xhr, type, errorThrown) {
				}
			});
			function tel1(e){
				var tel=e.getAttribute("name").split("_")[1];
				window.webkit.messageHandlers.tel1.postMessage(tel);
			}
			function tel2(e){
				var tel=e.getAttribute("name").split("_")[1];
				window.webkit.messageHandlers.tel2.postMessage(tel);
			}
			function tel3(e){
				var tel=e.getAttribute("name").split("_")[1];
				window.webkit.messageHandlers.tel3.postMessage(tel);
			}
			function tel4(e){
				var tel=e.getAttribute("name").split("_")[1];
				window.webkit.messageHandlers.tel4.postMessage(tel);
			}
			document.getElementById("vclFltServiceSation").addEventListener("tap",function(){
				window.webkit.messageHandlers.vclFltServiceSation.postMessage(vclid);
			});
			//获取位置
			function getPosition(){
							mui.ajax('../../../APP/position',{
				data:{param:'{"proVersion":"'+proversion+'","accountId":"'+accountid+'","sessionid":"'+sessionid+'","data":{"vclids":"'+vclid+'","lngs":"'+lng+'","lans":"'+lat+'"}}'},
				dataType:'jsonp',//服务器返回json格式数据
				type:'post',//HTTP请求类型
				timeout:10000,//超时时间设置为10秒；
				success:function(data){
					var jsonObj = window.JSON.parse(data);
					//document.getElementById("test").innerHTML="bb";
					if(jsonObj.resultcode=="1"){
						//document.getElementById("test").innerHTML=jsonObj.resultcode;
						//获取返回数据的data
						var resultdata = jsonObj.data;
							if(null !=resultdata){
								//document.getElementById("test").innerHTML="chang";
								for(var i=0;i<resultdata.length;i++){
									var arr = resultdata[i];
									//document.getElementById("test").innerHTML=resultdata[i][1];
										var psosit = resultdata[i][1];
										if(psosit.length>15){
											psosit = psosit.substring(0,15)+"...";
										}
										document.getElementById("lastPosition").innerHTML=psosit;
									
								}
							}else{
								//document.getElementById("test").innerHTML="null";
							}
						
					}else{
						//document.getElementById("test").innerHTML="null2";
					}
				},
				error:function(xhr,type,errorThrown){
					//异常处理；
					//document.getElementById("test").innerHTML=="error";
				}
			});
			}
</script>
	</body>

</html>